]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
Replace _getIndexOfDisplayedActor with a function in OverflowList
authorSiegfried-Angel Gevatter Pujals <rainct@ubuntu.com>
Thu, 6 Aug 2009 17:51:11 +0000 (19:51 +0200)
committerSiegfried-Angel Gevatter Pujals <rainct@ubuntu.com>
Thu, 6 Aug 2009 17:51:11 +0000 (19:51 +0200)
Said function in genericDisplay.js was returning the index of the
actor based upon its position in the entire list, while everywhere
else indexes relative to the currently displayed page were used.

This made actions in the details pane break (bug #590949), so I
replace it with a new function in shell-overflow-list.c,
shell_overflow_list_get_actor_index, which is page based.

js/ui/genericDisplay.js
src/shell-overflow-list.c
src/shell-overflow-list.h

index ba26cb3778f65acfd8f1528f258209ee5a21be68..0d7a2ab070b36b8809dc1cdb3ca98d9fb2b12c1d 100644 (file)
@@ -532,14 +532,14 @@ GenericDisplay.prototype = {
                             Lang.bind(this,
                                       function() {
                                           // update the selection
-                                          this._selectIndex(this._getIndexOfDisplayedActor(displayItem.actor));
+                                          this._selectIndex(this._list.get_actor_index(displayItem.actor));
                                           this.activateSelected();
                                       }));
 
         displayItem.connect('show-details',
                             Lang.bind(this,
                                       function() {
-                                          let index = this._getIndexOfDisplayedActor(displayItem.actor);
+                                          let index = this._list.get_actor_index(displayItem.actor);
                                           /* Close the details pane if already open */
                                           if (index == this._openDetailIndex) {
                                               this._openDetailIndex = -1;
@@ -557,7 +557,7 @@ GenericDisplay.prototype = {
     _removeDisplayItem: function(itemId) {
         let count = this._list.displayedCount;
         let displayItem = this._displayedItems[itemId];
-        let displayItemIndex = this._getIndexOfDisplayedActor(displayItem.actor);
+        let displayItemIndex = this._list.get_actor_index(displayItem.actor);
 
         if (this.hasSelected() && count == 1) {
             this.unsetSelected();
@@ -766,17 +766,6 @@ GenericDisplay.prototype = {
         return null;
     },
 
-    // Returns and index that the actor has in the ordering of the display's
-    // children.
-    _getIndexOfDisplayedActor: function(actor) {
-        let children = this._list.get_children();
-        for (let i = 0; i < children.length; i++) {
-            if (children[i] == actor)
-                return i;
-        }
-        return -1;
-    },
-
     // Selects (e.g. highlights) a display item at the provided index,
     // updates this.selectedItemDetails actor, and emits 'selected' signal.
     _selectIndex: function(index) {
index 77da1ad669c7b69aafc3ef8f9180a2ae709cabba..59511803af7b8ccb9a3a0b450b99761f9673b795 100644 (file)
@@ -386,3 +386,40 @@ shell_overflow_list_get_displayed_actor (ShellOverflowList *self,
 
   return iter->data;
 }
+
+/**
+ * shell_overflow_list_get_actor_index:
+ * @self:
+ * @actor: a child of the list
+ *
+ * Returns the index on the current page of the given actor.
+ *
+ * Return value: index of @actor in
+ * the currently visible page
+ */
+int
+shell_overflow_list_get_actor_index (ShellOverflowList *self,
+                                     ClutterActor      *actor)
+{
+  GList *children, *iter;
+  int i;
+
+  children = clutter_container_get_children (CLUTTER_CONTAINER (self));
+
+  if (children == NULL)
+    return NULL;
+
+  iter = g_list_nth (children, (self->priv->page) * self->priv->items_per_page);
+
+  int result = -1;
+  for (i = 0; iter; iter = iter->next, i++)
+    if (iter->data == actor)
+      {
+        result = i;
+        break;
+      }
+
+  g_list_free (children);
+
+  return result;
+}
index c8a912ed630d1d4fd0fadf17aeb0b4e563022438..c424fa415382996b7eecb57fafe2c9bb9c9ab49d 100644 (file)
@@ -37,6 +37,7 @@ struct _ShellOverflowListClass
 GType shell_overflow_list_get_type (void) G_GNUC_CONST;
 
 ClutterActor *shell_overflow_list_get_displayed_actor (ShellOverflowList *list, guint index);
+int shell_overflow_list_get_actor_index (ShellOverflowList *list, ClutterActor *actor);
 
 G_END_DECLS